// 使用快慢指针，遇到非去除的元素再移动slow
#include <iostream>
#include <vector>
using namespace std;

int removeDuplicates(vector<int> &nums) {
    if (nums.size() == 0)
        return 0;
    int slow = 0, fast = 0;

    while (fast < nums.size()) {
        if (nums[fast] != nums[slow]) {
            slow++;
            nums[slow] = nums[fast];
        }
        fast++;
    }
    return slow + 1;
}